package com.lyc.campuslife.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import static com.lyc.campuslife.utils.HttpRequestConstants.USER_INFO;

public class LoginInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        if(request.getAttribute(USER_INFO)==null){
            response.setStatus(401);
            return false;
        }
        //6 放行
        return true;
    }

}
